﻿using Microsoft.Extensions.Logging;
using RBAC.MaHaiBo.Entity;
using RBAC.MaHaiBo.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RBAC.MaHaiBo.Service
{
    public class CountyService : ICountyService
    {
        /// <summary>
        /// 日志
        /// </summary>
        ILogger<CountyService> logger;
        /// <summary>
        /// 县仓储
        /// </summary>
        ICountyRepository couRep;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger">日志</param>
        /// <param name="couRep">县仓储</param>
        public CountyService(ILogger<CountyService> logger,
         ICountyRepository couRep
         )
        {
            this.logger = logger;
            this.couRep = couRep;
        }

        /// <summary>
        /// 县
        /// </summary>
        /// <returns>返回县信息列表</returns>
        public async Task<List<County>> GetCounty(int cityId)
        {
            try
            {
                return await couRep.GetAsync(p => p.cityId == cityId);
            }
            catch (Exception ex)
            {
                logger.LogError("【县服务层】 县信息列表" + ex.Message);
                throw;
            }
        }
    }
}
